home *** CD-ROM | disk | FTP | other *** search
/ Amiga News 95 / Amiga News 95.iso / dpat / dpat13 / sources / sources.lha / consultation.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-16  |  2.2 KB  |  115 lines

  1.  
  2. #ifndef CONSULTATION_C
  3. #define CONSULTATION_C
  4. /*
  5. **      $Filename: Consultation.c $
  6. **      $Revision: 1.2 $
  7. **      $Release: 2.2 $
  8. **      $Date: 92/09/16 $
  9. **
  10. **
  11. **      (C) Copyright 1992 David Scrève
  12. **          All Rights Reserved
  13. */
  14.  
  15. #include <dos/dosextens.h>
  16.  
  17. #include "structures.h"
  18. #include "EXVariables_globales.h"
  19.  
  20. /* Prototypes */
  21.  
  22. BOOL SmallForbid();
  23. struct programme consultation();
  24. LONG nombremprunts();
  25. BOOL nouveau();
  26.  
  27. /* Code C */
  28.  
  29. BOOL nouveau(abcs)
  30. LONG abcs;
  31. {
  32.  LONG indicelue;
  33.  BOOL resultat=FALSE;
  34.  
  35.  nouveautes=(struct FileHandle *)Open(&news_nom[0],MODE_READWRITE);
  36.  if (nouveautes!=NULL)
  37.    {
  38.     do
  39.       retour=Read(nouveautes,&indicelue,sizeof(indicelue));
  40.     while ( retour>>0 && indicelue!=abcs);
  41.     resultat=(indicelue==abcs);
  42.     Close(nouveautes);
  43.    }
  44.  return (resultat);
  45. }
  46.  
  47. LONG nombremprunts(indic)
  48. LONG indic;
  49. {
  50.   LONG nb_emp=-1;
  51.   LONG RealIndic;
  52.  
  53.   RealIndic=(indic/(LONG)sizeof(struct programme));
  54.   RealIndic*=sizeof(nb_emp);
  55.  
  56.   emprunts=(struct FileHandle *)Open(&emprunts_nom[0],MODE_READWRITE);
  57.   if (emprunts!=NULL)
  58.        {
  59.         retour=Seek(emprunts,RealIndic,OFFSET_BEGINNING);
  60.         retour=Read(emprunts,&nb_emp,sizeof(nb_emp));
  61.         Close(emprunts);
  62.        }
  63.  if (retour<=0)
  64.      nb_emp=-1;
  65.  return(nb_emp);
  66. }
  67.  
  68. struct programme consultation(indi)
  69. LONG indi;
  70. {
  71.  struct programme prgtmp;
  72.  
  73.  retour=-1;
  74.  prgtmp.nom[0]=0;
  75.  prog=(struct FileHandle *)Open(&prog_nom[0],MODE_READWRITE);
  76.   if (prog!=NULL)
  77.       {
  78.        retour=Seek(prog,indi,OFFSET_BEGINNING);
  79.        retour=Read(prog,&prgtmp,sizeof(struct programme));
  80.        Close(prog);
  81.       }
  82.  if (retour==0 || retour==-1)
  83.      {
  84.       prgtmp.nom[0]=0;
  85.  
  86. /* New for Release 2.2 : compatible with older use but return now the */
  87. /* number of the error occured */
  88.  
  89.       if (retour==NULL)
  90.             prgtmp.taille=EOF_REACHED;
  91.           else
  92.             prgtmp.taille=IoErr();
  93.      }
  94.  return(prgtmp);
  95. }
  96.  
  97. BOOL SmallForbid(abcs)
  98. LONG abcs;
  99. {
  100.  LONG indicelue;
  101.  BOOL resultat=FALSE;
  102.  
  103.  progX=(struct FileHandle *)Open(&progX_nom[0],MODE_READWRITE);
  104.  if (progX!=NULL)
  105.    {
  106.     do
  107.       retour=Read(progX,&indicelue,sizeof(indicelue));
  108.     while ( retour>>0 && indicelue!=abcs);
  109.     resultat=(indicelue==abcs);
  110.     Close(progX);
  111.    }
  112.  return (resultat);
  113. }
  114.  
  115. #endif /* CONSULTATION_C */